home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_12_05 / tsai / toknizer.h < prev   
Encoding:
C/C++ Source or Header  |  1994-03-01  |  1.4 KB  |  38 lines

  1.  
  2. Listing 3: Definition of the class Tokenizer
  3.  
  4. _CLASSDEF(Tokenizer)
  5. class _CLASSTYPE Tokenizer
  6. {
  7. public:
  8.     Tokenizer(){}     // constructor
  9.     Tokenizer(ifstream&);    // constructor which takes a file stream
  10.     Tokenizer(const LPSTR);  // constructor which takes a file name
  11.     ~Tokenizer()      // destructor
  12.     {fis->close();
  13.      delete fis;}
  14.     Token * lookToken();     // look at the current token
  15.     Token * getToken();      // get a new token from the file stream
  16.     Token * peekToken();     // look ahead a token without moving
  17.                              // the file pointer
  18.     int getLineNo() { return nLineNo;}
  19.     BOOL eof() { return seof;}
  20.     BOOL good() { return status;}
  21.  
  22.     virtual void initialize(){}  // virtual function defined in child class
  23.  
  24. protected:
  25.     BOOL seof;                // end of file indicator
  26.     BOOL status;              // status of the constructor
  27.     char chcurr;              // current char
  28.     Token tcurr;              // current token
  29.     Token tpeek;              // peek token
  30.     int nLineNo;
  31. private:
  32.     void getChar();           // get one char from the ifstream
  33.     void getString();         // get one string
  34.     void skipComments();      // skip comments inside a file
  35.     void searchTokenType();   // determine the token type
  36.     ifstream * fis;      // file stream of the tokenizer
  37. };
  38.